<template>
  <ul class="contact-container">
    <li>
      <a :href="dataRef?.github">
        <div class="icon">
          <Icon :type="FontTypeEnum.Home" :size="iconSize"/>
        </div>
        <span>{{ dataRef?.github }}</span>
      </a>
    </li>
    <li>
      <a :href='`mailto:${dataRef?.mail }`'>
        <div class="icon">
          <Icon :type="FontTypeEnum.Home" :size="iconSize"/>
        </div>
        <span>{{ dataRef?.mail }}</span>
      </a>
    </li>
    <li>
      <a
        :href="`tencent://message/?Menu=yes&uin=${dataRef?.qq}&Service=300&sigT=45a1e5847943b64c6ff3990f8a9e644d2b31356cb0b4ac6b24663a3c8dd0f8aa12a595b1714f9d45`"
      >
        <div class="icon">
          <Icon :type="FontTypeEnum.Home" :size="iconSize"/>
        </div>
        <span ref="qqSpanRef">{{ dataRef?.qq }}</span>
      </a>
      <div class="pop" :style="{left:qqPopLefRef+'px',}">
        <img
        :src="dataRef?.qqQrCode"
          alt=""
        />
      </div>
    </li>
    <li>
      <a>
        <div class="icon weixin">
          <Icon :type="FontTypeEnum.Home" :size="iconSize"/>
        </div>
        <span ref="wxSpanRef">{{ dataRef?.weixin }}</span>
        <div class="pop" :style="{left:wxPopLeftRef+'px',}">
            <img
            :src="dataRef?.weixinQrCode"
            alt=""
            />

        </div>
      </a>
      
    </li>
  </ul>
</template>
<script setup lang="ts">
////#region defineXxx
//defineOptions({
//name:
//});

//const props=defineProps({
//propA:{
//type:String,
//required:true
//},
//propB:{
//type:Number,
//default:1
//},
//propC:{
//type:String as PropType<MyType>,
//required:true
//},
//});

//const emit = defineEmits<{
//event1:[para1:number,para2:string],
//event2:[para1:number,para2:string],
//}>();
////#endregion

import { useSettingsStore } from "~@/store/modules/settings";
const {dataRef}=storeToRefs(useSettingsStore());

import Icon from "~@/components/Icon/index.vue";
import { FontTypeEnum } from "~@/components/Icon/types";
import codeImg from "~@/assets/code.png"
import { onMounted,ref } from "vue";
import { storeToRefs } from "pinia";

const iconSize=18;
const wxSpanRef=ref<HTMLElement>();
const qqSpanRef=ref<HTMLElement>();

const calLeft=(dom:HTMLElement)=>{
    // if(wxSpanRef.value){
    //     if(getComputedStyle(wxSpanRef.value).display==='static')
    // }
    let left=0;
    if(dom){
        // console.log(getComputedStyle(wxSpanRef.value).left);
        // console.log(wxSpanRef.value.offsetLeft);
        // console.log(wxSpanRef.value.offsetWidth);
        return dom.offsetLeft+dom.offsetWidth
    }
    //console.log(left);  
    return left;
}

const wxPopLeftRef=ref(-10000);
const qqPopLefRef=ref(-10000);

onMounted(()=>{
    let popLeft=calLeft(wxSpanRef.value as HTMLElement) ;
    wxPopLeftRef.value=popLeft+10;
    qqPopLefRef.value=calLeft(qqSpanRef.value as HTMLElement)+10;
    // console.log(wxPopLeftRef.value);
    // console.log(qqPopLefRef.value);
    
})



</script>
<style lang="less" scoped>
.contact-container {
  list-style: none;
  padding: 20px;
  margin: 0;
  color: @gray;
  @itemHeight: 30px;
  li {
    height: @itemHeight;
    line-height: @itemHeight;
    margin: 10px 0;
    position: relative;
    &:hover {
      .pop {
        transform: scaleX(100%);
      }
    }
  }
  a {
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 16px;
    text-decoration: none;
    color: @gray;
  }
  .icon {
    text-align: center;
    width: 36px;
    & .weixin {
    //   font-size: 32px;
    //   text-indent: -3px;
    }
  }
  .pop {
    position: absolute;
    left: 0;
    top: -70px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 5px;
    transform: scaleX(0) ;
    transform-origin: center left;
    transition: 0.3s;
    img {
      width: 150px;
      height: 150px;
    }
    &::after {
      content: "";
      position: absolute;
      left: 0;
      top:82px;
      transform: translateX(-50%) rotate(45deg);
      width: 8px;
      height: 8px;
      background: #fff;
      
    }
  }
}
</style>
